package com.ruoyi.business.mapper;

import cn.hutool.core.date.DateTime;
import com.ruoyi.business.domain.SmsPushRecordDetails;
import com.ruoyi.business.domain.vo.SmsPushRecordDetailsVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import com.ruoyi.sms.domain.bo.DwSmsBO;
import com.ruoyi.sms.domain.dto.DewinSendSmsResponse;

/**
 * 短信发送记录详情Mapper接口
 *
 * @author ruoyi
 * @date 2024-04-20
 */
public interface SmsPushRecordDetailsMapper extends BaseMapperPlus<SmsPushRecordDetailsMapper, SmsPushRecordDetails, SmsPushRecordDetailsVo> {


    /**
     * 插入短信发送记录
     * @param dwSmsBO
     * @param response
     * @return
     */
    default int insertSmsSendRecord(DwSmsBO dwSmsBO, DewinSendSmsResponse response) {
        // 发送记录
        SmsPushRecordDetails smsPushRecordDetailDO = new SmsPushRecordDetails();
        smsPushRecordDetailDO.setPhone(dwSmsBO.getPhones());
        smsPushRecordDetailDO.setSignName(dwSmsBO.getSignName());
        smsPushRecordDetailDO.setServiceType(0L);
        smsPushRecordDetailDO.setTemplateCode(dwSmsBO.getTemplateCode());
        smsPushRecordDetailDO.setTemplateParam(dwSmsBO.getTemplateParam());
        smsPushRecordDetailDO.setResponseMsg(response.getMessage());
        smsPushRecordDetailDO.setResponseCode(response.getCode());
        smsPushRecordDetailDO.setBizId(response.getBizId());
        smsPushRecordDetailDO.setCreateTime(DateTime.now());
        smsPushRecordDetailDO.setSms(dwSmsBO.getSms());
        return this.insert(smsPushRecordDetailDO);
    }

}
